<?php


    // Author: Tomasz Durka
    // Date: 4th April 2007
    // Prints out a HTML submit tag
    
    
  function file_input ($name, array $params = array()) {
    $flat_name = $name;
    $flat_name = str_replace('[', '_', $flat_name);
    $flat_name = str_replace(']', '', $flat_name);
    $flat_name = strtolower($flat_name);
    if ($params['id']) {
      $id = " id=\"{$params['id']}\"";
    } else {
      $id = " id=\"{$name}\"";
    }
    $class = isset($params['class']) ? " class=\"{$flat_name} {$params['class']}\"" : " class=\"{$flat_name}\"";
    $style = " style=\"{$params['style']}\"";
    $size = " size=\"{$params['size']}\"";
    $on_change = " onChange=\"{$params['on_change']}\"";
    $on_focus = " onFocus=\"{$params['on_focus']}\"";
    $on_blur = " onBlur=\"{$params['on_blur']}\"";
    if (isset($params['disabled']) && $params['disabled'] === true) { 
      $disabled = " disabled=\"disabled\"";
    }
    
    # Type assign
    $type = 'file';
    
    
    if (isset($params['multiline']) && $params['multiline'] == true) {
      $returned = "<textarea name=\"{$name}\" {$class}{$style}{$id}>{$value}</textarea>";
    } else {
      $returned = "<input type=\"{$type}\" name=\"{$name}\" value=\"{$value}\"{$class}{$style}{$id}{$size}{$on_change}{$on_focus}{$on_blur}{$disabled} />";
    }
    //$returned = htmlspecialchars($returned);
    return $returned;
  }

?>